Ext.define("AM.view.deptView", {
	extend: 'Ext.tree.Panel',
	alias: 'widget.deptTree', //别名
	titile: '部门',
	width: 350,
	height: 500,
	padding: '5 3 3 10',  //填充跟css类似 上-右-下-左
	rootVisible: false,  //是否显示根节点
	config: {
		copyNodes: ''  //充当剪切板的作用
	},
	columns: [
		{xtype: 'treecolumn', text: 'text', width: 200, dataIndex: 'text'},
		{text: 'info', dataIndex: 'id'}
	],
//	使得节点可以移动
	viewConfig: {
		plugins: {
			ptype: 'treeviewdragdrop',  //ptype!!!
			appendOnly: true
		},
		//添加移动节点的监听事件
		listeners: {
			drop: function(node, data, overModel, dropPosition, eOpts) {
				Ext.MessageBox.alert("提示信息", "把 " +　data.records[0].get('text') + " 移动到 " + overModel.get('text'));
			},
			//
			beforedrop: function(node, data, overModel, dropPosition, dropFunction, eOpts ) {
				if (overModel.get('leaf')) {
					overModel.set('leaf', false);
				}
			}
		}
	},
	//添加按钮
	dockedItems: [{
		xtype: 'toolbar',  //工具条
		dock: 'left',  //工具条的位置
		//ui: 'footer',
		items: [
			{xtype: 'button', text: 'add', id: 'add'},
			{xtype: 'button', text: 'copy', id: 'copy'},
			{xtype: 'button', text: 'delete', id: 'delete'},
			{xtype: 'button', text: 'paste', id: 'paste'}
		]
	}, {
		//添加工具条
		xtype: 'toolbar',
		dock: 'top',
		items: [
			{ xtype: 'button', text: '展开所有', id: 'allOpen' },
			{ xtype: 'button', text: '收起所有', id: 'allClose' }
		]
	} ],
	//store: 'deptStore'  //关联store层
	//下面的数据是通过后台获取的而不是采用硬编码形式指定
//	树根
	root: {
		id: '0',
		text: '部门',
		leaf: false,
		children: [
			{
				id: '01',
				text: '技术部门',
				checked: false,
				leaf: false,
				children: [
					{
						id: '0101',
						checked: false,
						text: '研发部',
						leaf: true,
					},
					{
						id: '0102',
						checked: false,
						text: '实施部',
						leaf: true,
					}
				]
			},
			{
				id: '02',
				text: '后勤部门',
				leaf: false,
				checked: false,
				children: [
					{
						id: '0201',
						checked: false,
						text: '人事部',
						leaf: true,
					},
					{
						id: '0202',
						checked: false,
						text: '采购部',
						leaf: true,
					}
				]
			}
		]
	}
});